package com.gexin.model.activity;

import com.gexin.common.utils.SQLUtils;
import com.gexin.model.activity.base.BaseMemberCommisionLog;
import org.apache.commons.lang3.StringUtils;

import java.math.BigDecimal;
import java.util.Date;
import java.util.List;

/**
 * 业务名称:  t_member_commision_log()
 */
@SuppressWarnings("serial")
public class MemberCommisionLog extends BaseMemberCommisionLog<MemberCommisionLog> {
	public static final MemberCommisionLog dao = new MemberCommisionLog();


	public void setMemberCommisionLogByUserId( String userId,String openid,BigDecimal balance,BigDecimal commission,
											   int enter_type, long applyTime,String desc,int status
											   ) {
		this.setId(System.currentTimeMillis()/1000+"");
		this.setBalance(balance);
		this.setOpenid(openid);
		this.setEnterType(enter_type);
		this.setApplyTime(applyTime);
		this.setCommission(commission);
		this.setUserId(userId);
		this.setStatus(status);
		long date = new Date().getTime();
		this.setCreateTime(date);
		this.setUpdateTime(date);
	}


	public MemberCommisionLog getMemberCommisionLogById(String id, int status) {
		MemberCommisionLog memberCommisionLog = MemberCommisionLog.dao.findFirst(
				"select * from t_member_commision_log where user_id=? and status=?", new Object[]{id, status});
		return memberCommisionLog;
	}


	public MemberCommisionLog getMemberComissionLog(String id){
		 MemberCommisionLog commision  = MemberCommisionLog.dao.findFirst(
				"select * from t_member_commision_log where id="+id +" order by create_time desc");
		return commision;
	}

	public List<MemberCommisionLog> getCommision(String id){
		List<MemberCommisionLog> commisionList = MemberCommisionLog.dao.find(
				"select * from t_member_commision_log where user_id="+id +" order by create_time desc");
		return commisionList;
	}

}
